const User = require('./user');
const Topic = require('./topic');
const Types = require('./type');
const Comment = require('./comment');
User.hasMany(Topic, {
  as: 'topic',
  foreignKey: 'author_id',
});
Topic.belongsTo(User, {
  foreignKey: 'author_id',
});
Types.hasMany(Topic, {
  foreignKey: 'type',
});

Topic.hasMany(Comment, {
  foreignKey: 'topic_id',
});

User.hasMany(Topic, {
  foreignKey: 'author_id',
});

User.hasMany(Comment, {
  foreignKey: 'fromId',
});
Comment.belongsTo(User, {
  foreignKey: 'fromId',
});

Comment.hasMany(Comment, {
  foreignKey: 'replayId',
  as: 'Comments',
});
